'use strict'

define(['jquery', 'bootstrap', 'shiftform', 'validate', 'validate.en', 'datetimepicker', 'datetimepickerCN', 'select2'], function($) {
  
  return {
        
    init: function() {
        this.initUse();
        this.initExport();
    },
    
    initUse: function(){
        $(document).on("shown.bs.modal", "#use", function(e) {
            var $form = $(e.currentTarget).find("form");
            
            $form.bt_validate();
            $form.shiftform({
                beforeSubmit: function(el) {
                  $('form').trigger("validate.ajax.submit");
                       return $.bt_validate.result[$.bt_validate.form_id]
                }
            });
        });
    },
    
    initExport: function(){
        $(document).on('shown.bs.modal', ' #export', function(e){
            
            $(e.currentTarget).find('form[data-validate="true"]').bt_validate();  //bind validate

            $('button[type="submit"').click(function() {
                $(e.currentTarget).find("form").trigger("validate.ajax.submit");
                $.bt_validate.result[$.bt_validate.form_id];
            });
        })
    }
   }
})
